package com.wnxy.pms.member.core.controller;


import com.wnxy.pms.common.api.Result;
import com.wnxy.pms.member.core.dto.UserDto;
import com.wnxy.pms.member.core.entity.User;
import com.wnxy.pms.member.core.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员用户表 前端控制器
 * </p>
 *
 * @author Jet
 * @since 2022-06-07
 */
@RestController
@RequestMapping("/user")
@Slf4j
@Api(tags = "用户微服务")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 登陆认证, 认证成功返回token
     */
    @PostMapping("/login")
    @ApiOperation("登陆认证")
    public Result<String> login(@RequestBody @Validated UserDto userDto){
        log.info("认证方法，{}",userDto);
        String token = userService.login(userDto);
        return Result.ok(token);
    }
}

